package com.leetcode.LC;


public class LC404 {
    int sum = 0;

    public int sumOfLeftLeaves(TreeNode root) {

        if (root==null){
            return 0;
        }
        zhongxuDigui(root);
        return sum;

    }

    // 用递归的方法进行中序遍历
    public void zhongxuDigui(TreeNode treeNode) {
        if (treeNode.left != null) {
            if (treeNode.left.right == null && treeNode.left.left == null) {
                sum += treeNode.left.val;
            }
            zhongxuDigui(treeNode.left);
        }

        if (treeNode.right != null) {
            zhongxuDigui(treeNode.right);
        }
    }

}
